# Maintainer: BlackIkeEagle < ike DOT devolder AT gmail DOT com >
# Contributor: Giancarlo Razzolini <grazzolini@archlinux.org>
# Contributor: Alexander F Rødseth <xyproto@archlinux.org>
# Contributor: Lukas Fleischer <lfleischer@archlinux.org>
# Contributor: Alexander Baldeck <alexander@archlinux.org>
# Contributor: Denis A. Altoe Falqueto <denisfalqueto@gmail.com>

pkgbase=projectm
pkgname=('projectm' 'projectm-sdl' 'projectm-pulseaudio')
pkgver=3.1.12
pkgrel=4
arch=('loong64' 'x86_64')
url='https://github.com/projectM-visualizer/projectm'
license=('LGPL')
makedepends=('mesa-libgl' 'glm' 'qt5-base' 'ftgl' 'glew' 'sdl2' 'libpulse')
source=("https://github.com/projectM-visualizer/$pkgbase/releases/download/v$pkgver/projectM-$pkgver.tar.gz")
sha256sums=('b6b99dde5c8f0822ae362606a0429628ee478f4ec943a156723841b742954707')

build() {
    cd "projectM-$pkgver"
    ./configure --prefix=/usr --enable-gles --enable-sdl --enable-threading --enable-qt
    sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool # Fix overlinking
    make
}

package_projectm() {
    pkgdesc='Music visualizer which uses 3D accelerated iterative image based rendering'
    depends=('libgl' 'glm' 'ftgl' 'glew')


    cd "$srcdir/projectM-$pkgver"
    make DESTDIR="$pkgdir" install-data-am
    cd "$srcdir/projectM-$pkgver/src"
    make DESTDIR="$pkgdir" install-am
    cd "$srcdir/projectM-$pkgver/src/libprojectM"
    make DESTDIR="$pkgdir" install
    cd "$srcdir/projectM-$pkgver/src/NativePresets"
    make DESTDIR="$pkgdir" install

    find "$pkgdir" -iname "\.*" -delete
}

package_projectm-sdl() {
    pkgdesc='Music visualizer which uses 3D accelerated iterative image based rendering (sdl)'
    depends=('projectm' 'sdl2')

    cd "$srcdir/projectM-$pkgver/src/projectM-sdl"
    make DESTDIR="$pkgdir" install
}

package_projectm-pulseaudio() {
    pkgdesc='Music visualizer which uses 3D accelerated iterative image based rendering (pulseaudio)'
    depends=('projectm' 'qt5-base' 'libpulse')

    cd "$srcdir/projectM-$pkgver/src/projectM-pulseaudio"
    make DESTDIR="$pkgdir" install
}
